import paramiko, os
hostname = '192.168.1.71'
port = 22
username = 'root'
password = '123.com'
local_path = os.path.join(os.getcwd(), 'id_rsa')
remote_path = '/opt/id_rsa'

s = paramiko.Transport((hostname, port))
s.connect(username=username,password=password)
sftp = paramiko.SFTPClient.from_transport(s)
sftp.put(local_path, remote_path)
